package com.js.nickcar.api;


import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by 李宗源 on 2017/4/26.
 */

public class HttpHelpter {

    private static APIService apiService;
    private static Retrofit retrofit;

    public static APIService getApiService() {
        if (apiService == null) {
            apiService = getRetrofit().create(APIService.class);
        }
        return apiService;
    }

    public static Retrofit getRetrofit() {
        if (retrofit == null) {
            retrofit = new Retrofit.Builder()
                    .baseUrl(UrlUtils.BASE_URL)
                    .addConverterFactory(GsonConverterFactory.create())
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .build();
        }
        return retrofit;
    }

}
